home *** CD-ROM | disk | FTP | other *** search
/ Champak 106 / Vol 106.iso / interfac / it.dig / scripts / __Packages / mx / controls / UIScrollBar.as < prev    next >
Encoding:
Text File  |  2010-04-12  |  6.8 KB  |  261 lines

  1. class mx.controls.UIScrollBar extends mx.controls.scrollClasses.ScrollBar
  2. {
  3.    var textField;
  4.    var wasHorizontal;
  5.    var __width;
  6.    var __height;
  7.    var width;
  8.    var hPosition;
  9.    var hscroll;
  10.    var vPosition;
  11.    var scroll;
  12.    var synchScroll;
  13.    var hScroller;
  14.    var vScroller;
  15.    var onChanged;
  16.    var onScroller;
  17.    var isScrolling;
  18.    var horizontal;
  19.    var scrollPosition;
  20.    var dispatchEvent;
  21.    static var symbolName = "UIScrollBar";
  22.    static var symbolOwner = mx.controls.UIScrollBar;
  23.    var className = "UIScrollBar";
  24.    var clipParameters = {_targetInstanceName:1,horizontal:1};
  25.    static var mergedClipParameters = mx.core.UIObject.mergeClipParameters(mx.controls.UIScrollBar.prototype.clipParameters);
  26.    static var version = "2.0.2.126";
  27.    function UIScrollBar()
  28.    {
  29.       super();
  30.    }
  31.    function init(Void)
  32.    {
  33.       super.init();
  34.       this.textField.owner = this;
  35.       this.horizontal = this.wasHorizontal;
  36.       if(this.horizontal)
  37.       {
  38.          this.textField == undefined ? super.setSize(this.__width,this.__height) : super.setSize(this.textField._width,16);
  39.       }
  40.       else
  41.       {
  42.          this.textField == undefined ? super.setSize(this.__width,this.__height) : super.setSize(16,this.textField._height);
  43.       }
  44.       if(this.horizontal)
  45.       {
  46.          var _loc3_ = this.__width;
  47.          this.__height = this.__width;
  48.          this.width = _loc3_;
  49.          this.__width = 16;
  50.       }
  51.       this.textField.onScroller = function()
  52.       {
  53.          this.hPosition = this.hscroll;
  54.          this.vPosition = this.scroll - 1;
  55.       };
  56.       if(this._targetInstanceName != undefined)
  57.       {
  58.          this.setScrollTarget(this._targetInstanceName);
  59.          this._targetInstanceName.addListener(this);
  60.       }
  61.    }
  62.    function get _targetInstanceName()
  63.    {
  64.       return this.textField;
  65.    }
  66.    function get height()
  67.    {
  68.       if(this.wasHorizontal)
  69.       {
  70.          return this.__width;
  71.       }
  72.       return this.__height;
  73.    }
  74.    function get width()
  75.    {
  76.       if(this.wasHorizontal)
  77.       {
  78.          return this.__height;
  79.       }
  80.       return this.__width;
  81.    }
  82.    function size(Void)
  83.    {
  84.       super.size();
  85.       this.onTextChanged();
  86.    }
  87.    function draw()
  88.    {
  89.       super.draw();
  90.    }
  91.    function set _targetInstanceName(t)
  92.    {
  93.       if(t == undefined)
  94.       {
  95.          this.textField.removeListener(this);
  96.          delete this.textField[!this.horizontal ? "vScroller" : "hScroller"];
  97.          if(this.textField.hScroller != undefined && this.textField.vScroller != undefined)
  98.          {
  99.             this.textField.unwatch("text");
  100.             this.textField.unwatch("htmltext");
  101.          }
  102.       }
  103.       var _loc3_ = this._parent[t];
  104.       this.textField = this._parent[t];
  105.       this.onTextChanged();
  106.    }
  107.    function setSize(w, h)
  108.    {
  109.       if(this.horizontal)
  110.       {
  111.          super.setSize(h,w);
  112.       }
  113.       else
  114.       {
  115.          super.setSize(w,h);
  116.       }
  117.    }
  118.    function onTextChanged(Void)
  119.    {
  120.       if(this.textField == undefined)
  121.       {
  122.          return undefined;
  123.       }
  124.       clearInterval(this.synchScroll);
  125.       if(this.horizontal)
  126.       {
  127.          var _loc2_ = this.textField.hscroll;
  128.          this.setScrollProperties(this.textField._width,0,this.textField.maxhscroll);
  129.          this.scrollPosition = Math.min(_loc2_,this.textField.maxhscroll);
  130.       }
  131.       else
  132.       {
  133.          _loc2_ = this.textField.scroll;
  134.          var _loc3_ = this.textField.bottomScroll - this.textField.scroll;
  135.          this.setScrollProperties(_loc3_,1,this.textField.maxscroll);
  136.          this.scrollPosition = Math.min(_loc2_,this.textField.maxscroll);
  137.       }
  138.    }
  139.    function get horizontal()
  140.    {
  141.       return this.wasHorizontal;
  142.    }
  143.    function set horizontal(v)
  144.    {
  145.       this.wasHorizontal = v;
  146.       if(v and this.initializing)
  147.       {
  148.          if(this._rotation == 90)
  149.          {
  150.             return;
  151.          }
  152.          this._xscale = -100;
  153.          this._rotation = -90;
  154.       }
  155.       if(!this.initializing)
  156.       {
  157.          if(v)
  158.          {
  159.             if(this._rotation == 0)
  160.             {
  161.                this._rotation = -90;
  162.                this._xscale = -100;
  163.             }
  164.          }
  165.          else if(this._rotation == -90)
  166.          {
  167.             this._rotation = 0;
  168.             this._xscale = 100;
  169.          }
  170.       }
  171.    }
  172.    function callback(prop, oldval, newval)
  173.    {
  174.       clearInterval(this.hScroller.synchScroll);
  175.       clearInterval(this.vScroller.synchScroll);
  176.       this.hScroller.synchScroll = setInterval(this.hScroller,"onTextChanged",50);
  177.       this.vScroller.synchScroll = setInterval(this.vScroller,"onTextChanged",50);
  178.       return newval;
  179.    }
  180.    function setScrollTarget(tF)
  181.    {
  182.       if(tF == undefined)
  183.       {
  184.          this.textField.removeListener(this);
  185.          delete this.textField[!this.horizontal ? "vScroller" : "hScroller"];
  186.          if(this.textField.hScroller != undefined && this.textField.vScroller != undefined)
  187.          {
  188.             this.textField.unwatch("text");
  189.             this.textField.unwatch("htmltext");
  190.          }
  191.       }
  192.       this.textField = undefined;
  193.       if(!(tF instanceof TextField))
  194.       {
  195.          return undefined;
  196.       }
  197.       this.textField = tF;
  198.       if(this.horizontal)
  199.       {
  200.          this.textField.hScroller = this;
  201.          this.textField.hScroller.lineScrollSize = 5;
  202.       }
  203.       else
  204.       {
  205.          this.textField.vScroller = this;
  206.          this.textField.vScroller.lineScrollSize = 1;
  207.       }
  208.       this.onTextChanged();
  209.       this.onChanged = function(Void)
  210.       {
  211.          this.onTextChanged();
  212.       };
  213.       this.onScroller = function(Void)
  214.       {
  215.          if(!this.isScrolling)
  216.          {
  217.             if(!this.horizontal)
  218.             {
  219.                this.scrollPosition = this.textField.scroll;
  220.             }
  221.             else
  222.             {
  223.                this.scrollPosition = this.textField.hscroll;
  224.             }
  225.          }
  226.       };
  227.       this.textField.addListener(this);
  228.       this.textField.watch("text",this.callback);
  229.       this.textField.watch("htmlText",this.callback);
  230.    }
  231.    function scrollHandler(Void)
  232.    {
  233.       if(this.horizontal)
  234.       {
  235.          var _loc2_ = this.textField.background;
  236.          this.textField.hscroll = this.scrollPosition;
  237.          this.textField.background = _loc2_;
  238.       }
  239.       else
  240.       {
  241.          this.textField.scroll = this.scrollPosition;
  242.       }
  243.    }
  244.    function setEnabled(enable)
  245.    {
  246.       super.setEnabled(enable);
  247.       if(enable)
  248.       {
  249.          this.textField.addListener(this);
  250.       }
  251.       else
  252.       {
  253.          this.textField.removeListener();
  254.       }
  255.    }
  256.    function dispatchScrollEvent(detail)
  257.    {
  258.       this.dispatchEvent({type:"scroll"});
  259.    }
  260. }
  261.